<%@ page language="java"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <title>我的计划列表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!-- 引用新样式 start -->
  <jsp:include page="../../jsp/public.jsp" flush="true"/>
    <!-- end -->

    <script type="text/javascript" src="<%=basePath%>js/new/jquery.min.js" charset="utf-8"></script>
    <script src="<%=basePath%>/js/layer/layer.js"></script>
    <script>
        //跳转到新增进度页面
        function toAddProgress(id,result) {
        	if(result == "1"){
        		$("#mapId").val(id);
            	var data = $("#queryForm").serialize();
                window.location.href = "<%=path%>/bus/progress/addProgress?" + data;
        	}else{
        		msgPrompt("您上一次提交的进度还未审核通过,暂时不能提交新的进度！");
        	}
        }

        //修改频次
        function editReport(id, num) {
            $("#reportFreq").val(num);
            $('#myModalEdit').modal('show');
            $("#reportId").val(id);
        }

        //修改频次
        function determine() {
            var num = $("#reportFreq").val();
            var id = $("#reportId").val();
            var datas = {
                "reportFreq": num,
                "modelPlanId": id
            };
            $.ajax({
                url: '<%=path%>/bus/progress/editReport',
                data: datas,
                type: 'post',
                cache: false,
                async: false,
                success: function (data) {
                    var infoss = data.infoss;
                    if (infoss == 1) {
                        $("#infos").text("频数大于0");
                    } else {
                        $('#myModalEdit').modal('hide');
                        alert("修改成功！");
                        window.location.reload()//刷新当前页面
                    }
                },
                error: function (data) {
                    alert("修改出错!");
                }
            });
        }

        //接受
        function accept(id) {
            var url = "<%=path%>/bus/progress/accept?id=" + id;
            $.ajax({
                type: "post",
                url: url,
                data: id,
                dataType: "json",
                success: function (data) {
                    layer.msg(data.message, {
                        offset: 't',
                        anim: 1
                    }, function () {
                        window.location.href='<%=path%>/bus/meter/returnMeterGive?url=<%=path%>/bus/progress/myPlan&flg=queryPageBusModelPlan';
                    });
                }
            });
        }
    </script>
<body>
<div class="col-lg-12">
    <div class="index-nav-right">
        <div class="index-nav-right-header"><span>当前位置 > 厂商平台 > <b>我的计划</b></span></div>
    </div>
    <div class="right-table">
        <form id="queryForm" method="post" action="<%=path%>/bus/progress/myPlan">
        	<input hidden = "true" type = "text" id = "mapId" name = "mapId">
        	<input hidden = "true" type = "text" id = "mapPage" name ="mapPage" value="${map['page'] }">
            <div class="search-form">
                <div class="search-form-input">
                    <label>机种:</label>
                    <select name="modelType" id="modelType">
                        <option value="">请选择</option>
                        <c:if test="${not empty mTypeList}">
                            <c:forEach items="${mTypeList }" var="mTypeList"
                                       varStatus="m">
                                <option value="${mTypeList.targetName}"
                                        <c:if test="${map['modelType'] ==mTypeList.targetName }">selected</c:if>>${mTypeList.targetName}</option>
                            </c:forEach>
                        </c:if>
                    </select>
                </div>

                <div class="search-form-input" style="border: 0px solid red">
                    <label>难易度:</label>
                    <select name="modelLevel" id="modelLevel">
                        <option value="" <c:if test="${map['modelLevel'] =='' }">selected</c:if>>请选择</option>
                        <option value="S" <c:if test="${map['modelLevel'] =='S' }">selected</c:if>>S</option>
                        <option value="A" <c:if test="${map['modelLevel'] =='A' }">selected</c:if>>A</option>
                        <option value="B" <c:if test="${map['modelLevel'] =='B' }">selected</c:if>>B</option>
                        <option value="C" <c:if test="${map['modelLevel'] =='C' }">selected</c:if>>C</option>
                    </select>
                </div>
                <div class="search-form-input">
                    <label>部品番号</label><input type="text" name="modelCode" id="modelCode"
                                              value="${map['modelCode'] }"/>
                </div>

                <div class="search-form-btn search-form-input" style="border: 0px solid red;">
                    <button type="submit" class="btn btn-primary search-form-btn-s" style="color: black;">
                        搜索
                    </button>
                </div>
            </div>

            <div class="index-table">
                <table class="table table-striped" action="<%=path%>/bus/progress/myPlan">
                    <thead>
                    <tr class="table-thead">
                        <th>序号</th>
                        <th>机种</th>
                        <th>部品番号</th>
                        <th>部品难易度</th>
                        <th>所属客户</th>
                        <th>计划开始</th>
                        <th>计划结束</th>
                        <th>实际开始</th>
                        <th>实际结束</th>
                        <th>进度状态</th>
                       <!--  <th>提醒频次</th> -->
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:if test="${not empty list}">
                        <c:forEach items="${list }" var="model" varStatus="r">
                            <tr>
                                <td>${r.index+1 }</td>
                                <td>${model.modelType }</td>
                                <td>${model.modelCode }</td>
                                <td>${model.modelLevel }</td>
                                <td>${model.customer }</td>
                                <td>${model.planStartTimeText }</td>
                                <td>${model.planEndTimeText }</td>
                                <td>${model.accStartTime }</td>
                                <td>${model.accEndTime }</td>
                                <td>${model.lastReportTimeText }</td>
                                <td id="${model.id }">
                                    <c:if test="${model.receiveFlag == 0 }">
                                        <span class="hand-like" onClick="accept(${model.modelPlanId})">接收</span>
                                    </c:if>
                                    <c:if test="${model.lastReportTimeText != '已提交' }">
	                                    <c:if test="${model.receiveFlag == 1 }">
	                                        <c:if test="${model.flag == 1 }">
	                                            <span class="hand-like" onClick="toAddProgress(${model.modelPlanId},${model.lastAuditResult})">提交进度</span>
	                                        </c:if>
	                                    </c:if>
                                    </c:if>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:if>
                    <c:if test="${empty list}">
                        <tr>
                            <td colspan="15"><label class="control-label text-center">无记录</label></td>
                        </tr>
                    </c:if>
                    </tbody>
                    <tr style="background: #f8f8f8">
                        <td colspan="12">
                            <jsp:include page="/WEB-INF/jsp/page.jsp"></jsp:include>
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </div>

    <!-- 修改频次 模态框（Modal） -->
    <div class="modal fade" id="myModalEdit" tabindex="-10" role="dialog" aria-labelledby="myModalLabelEdit"
         aria-hidden="true" style="border: 0px solid red">
        <div class="modal-dialog" style="border: 0px solid red;margin-top: 120px; ">
            <div class="modal-content" style="border: 0px solid red; width: 60%;margin: auto;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h3 class="modal-title" id="myModalLabelEdit">
                        邮件提醒频次修改
                    </h3>
                </div>
                <form id="defaultForm"
                      class="form-horizontal"
                      method="post" style="border: 0px solid red;">
                    <div class="modal-body">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">次数:</label>
                            <div class="col-sm-5">
                                <input type="hidden" id="reportId"/>
                                <input type="number" class="form-control" id="reportFreq" name="reportFreq"
                                       placeholder="" required/>
                                <p style="color:red;" id="infos"></p>
                            </div>

                        </div>

                    </div>
                    <div class="modal-footer">
                        <button id="editDetermine" type="button" class="btn btn-success" onclick="determine()">确定
                        </button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                        </button>

                    </div>
                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div><!-- /.end modal -->

</div>
<input type="hidden" class="hiddenId" id="modelPlanId" value="">
</body>
<script type="text/javascript" src="<%=basePath%>js/bootstrap-3.3.6/dist/js/bootstrap.min.js" charset="utf-8"></script>
</html>